<template>
  <Content title="验收">
    <view class="quality-confirmation-box">
      <u-form
        labelPosition="left"
        :model="model"
        labelWidth="120"
        labelAlign="left"
        :rules="rules"
        ref="uForm"
      >
        <u-form-item label="服务态度评分：" prop="serveScore" required>
          <uni-rate :max="5" v-model="model.serveScore" />
        </u-form-item>
        <u-form-item label="技术能力评分：" prop="technologyScore" required>
          <uni-rate :max="5" v-model="model.technologyScore" />
        </u-form-item>
        <u-form-item label="响应速度评分：" prop="responseScore" required>
          <uni-rate :max="5" v-model="model.responseScore" />
        </u-form-item>

 <!--       <u-form-item label="评语：" prop="evaluate" required>
          <u-textarea
            v-model="model.evaluate"
            placeholder="请输入"
          ></u-textarea>
        </u-form-item> -->
        <view class="btn-v">
          <view class="but-box">
            <u-button class="btn" @click="close" text="取消"></u-button>
            <u-button
              class="btn"
              type="primary"
              @click="submit"
              text="确定"
            ></u-button>
          </view>
        </view>
      </u-form>
    </view>
  </Content>
</template>

<script>
import Content from "@/components/content/index.vue";
import fetch from "@/utils/fetch";
export default {
  components: {
    Content,
  },
  data() {
    return {
      id: "",
      model: {
        serveScore: "",
        technologyScore: "",
        responseScore: "",
        // evaluate: "",
      },
      rules: {
        serveScore: {
          required: true,
          message: "请填写",
          trigger: "change",
        },
        technologyScore: {
          required: true,
          message: "请填写",
          trigger: "change",
        },
        responseScore: {
          required: true,
          message: "请填写",
          trigger: "change",
        },
        // evaluate: {
        //   required: true,
        //   message: "请填写",
        //   trigger: "change",
        // },
      },
    };
  },
  onLoad: function (option) {
    //option为object类型，会序列化上个页面传递的参数
    this.id = option.id;
  },
  onShow: function () {},
  mounted() {},
  methods: {
    close() {
      uni.navigateBack({
        delta: 1, //返回上一页
      });
    },
    submit() {
      if (!this.model.serveScore) {
        uni.$emit("openToast", {
          type: "error",
          title: "服务态度评分不能为空",
        });
        return;
      }
      if (!this.model.technologyScore) {
        uni.$emit("openToast", {
          type: "error",
          title: "技术能力评分不能为空",
        });
        return;
      }
      if (!this.model.responseScore) {
        uni.$emit("openToast", {
          type: "error",
          title: "响应速度评分不能为空",
        });
        return;
      }

      // if (!this.model.evaluate) {
      //   uni.$emit("openToast", {
      //     type: "error",
      //     title: "请输入评语",
      //   });
      //   return;
      // }
      const that = this;
      that.$loading.open();
      fetch("post", "/dms/devSpotCheckTask/affirmTask",null,{
        id: this.id,
        ...this.model,
      }).then((res) => {
        uni.$emit("openToast", {
          type: "success",
          title: "点检完成成功",
          complete() {
            uni.navigateBack({
              delta: 1, //返回上一页
            });
          },
        });
      });
    },
  },
};
</script>

<style scoped lang="scss">
.quality-confirmation-box {
  padding: 40rpx;
  background-color: #fff;
  min-height: 100%;
}
</style>
